import { v7 as uuid } from "uuid"
export function initCanvas(
    canvas: HTMLCanvasElement,
    width: number,
    height: number,
    mousedownCallback: (ev: any) => void,
    mousemoveCallback: (ev: any) => void,
    mouseupCallback: (ev: any) => void,
    mousewheelCallback: (ev: any) => void,
    mouseLeaveCallback: (ev: any) => void
) {
    canvas.width = width
    canvas.height = height
    canvas.style.width = "100%"
    canvas.style.height = "100%"
    canvas.id = uuid()
    canvas.addEventListener("contextmenu", (ev: MouseEvent) => {
        ev.preventDefault()
    })
    canvas.addEventListener("mousedown", (ev: any) => {
        ev.preventDefault()
        mousedownCallback(ev)
    })
    canvas.addEventListener("mouseup", (ev: any) => {
        mouseupCallback(ev)
    })
    canvas.addEventListener("wheel", (ev: any) => {
        ev.preventDefault()
        mousewheelCallback(ev)
    })
    canvas.addEventListener("mousemove", (ev: any) => {
        mousemoveCallback(ev)
    })
    canvas.addEventListener("mouseleave", (ev: any) => {
        mouseLeaveCallback(ev)
    })
}
